package pl.edu.agh.ssm.monitor.tests;

import jpcap.JpcapCaptor;
import jpcap.packet.Packet;
import jpcap.packet.UDPPacket;
import pl.edu.agh.ssm.monitor.listeners.PacketListener;
import pl.edu.agh.ssm.monitor.listeners.RTPSessionListener;
import pl.edu.agh.ssm.monitor.net.PacketFilter;
import pl.edu.agh.ssm.monitor.net.PacketReceiver;

public class PacketReceiverTest {

	public static void main(String[] args) {
		try {
			PacketReceiver receiver = new PacketReceiver(JpcapCaptor.getDeviceList()[1], false);
			PacketListener listener1 = new RTPSessionListener(receiver);
				listener1.setPriority(1);
			PacketListener listener2 = new RTPSessionListener(receiver);
				listener2.setPriority(2);
			PacketListener listener3 = new RTPSessionListener(receiver);
				listener3.setPriority(3);
			PacketListener listener4 = new RTPSessionListener(receiver);
				listener4.setPriority(4);
			PacketListener listener5 = new RTPSessionListener(receiver);
				listener5.setPriority(2);	
			
			PacketFilter filter = new PacketFilter();
			filter.setPort(0); 
			receiver.addPacketListener(listener2, filter);
			receiver.addPacketListener(listener3, filter);
			receiver.addPacketListener(listener4, filter);
			receiver.addPacketListener(listener1, filter);
			receiver.addPacketListener(listener5, filter);
			
			Packet packet = new UDPPacket(1001, 1002);
			receiver.receivePacket(packet);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
